using System;

namespace MvcFckEditor.Components
{
    internal class TypeConfig
	{
		public string[] AllowedExtensions{get;set;}
        public string[] DeniedExtensions { get; set; }
        public string FilesPath { get; set; }

		internal bool CheckIsAllowedExtension(string extension)
		{
			// Do not accept empty settings.
			if ( AllowedExtensions.Length == 0 && DeniedExtensions.Length == 0 )
				return false;

			if ( DeniedExtensions.Length > 0 && !Util.ArrayContains( DeniedExtensions, extension, System.Collections.CaseInsensitiveComparer.DefaultInvariant ) )
				return false;

			if ( AllowedExtensions.Length > 0 && !Util.ArrayContains( AllowedExtensions, extension, System.Collections.CaseInsensitiveComparer.DefaultInvariant ) )
				return false;

			return true;
		}
	}
}
